//
//  OrderManagerService.m
//  YYZB
//
//  Created by BY_R on 16/3/29.
//
//

#import "OrderManagerService.h"

@implementation OrderManagerService
//根据帮工Id获取订单我的订单首页订单数量统计
- (void)OrderCount:(NSString *)helperid completionHanlder:(void (^)(NSArray *items, NSError *error))completionHanlder{
    NSString *URL = @"HelperOrder/GetAllOrderCountByHelpId";
    NSDictionary *params = @{
                             @"HelperId": helperid,
                                                          
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:YES];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSArray *items = [self unboxedValue:result error:&err];
            completionHanlder(items, err);
        }
    }];
}
//所有待服务订单
-(void)waitServiceOrder:(NSString *)helperId pageNo:(NSString *)pageno pageSize:(NSString *)pagesize completionHanlder:(void (^)(NSArray *, NSError *))completionHanlder{
    NSString *URL = @"HelperOrder/GetStayOrderListByHelpId";
    NSDictionary *params = @{
                             @"HelperId": helperId,
                             @"PageNo": pageno,
                             @"PageSize":pagesize
                             
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:YES];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSArray *items = [self unboxedValue:result error:&err];
            completionHanlder(items, err);
        }
    }];
}
//抢单
-(void)grabOrder:(NSString *)helperid OrderId:(NSString *)orderid HelperAreaId:(NSString *)helperAreaid completionHanlder:(void (^)(NSArray *, NSError *))completionHanlder{
    NSString *URL = @"HelperOrder/GrabOrder";
    NSDictionary *params = @{
                             @"HelperId": helperid,
                             @"OrderId": orderid,
                             @"HelperAreaID":helperAreaid
                             
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:YES];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSArray *items = [self unboxedValue:result error:&err];
            completionHanlder(items, err);
        }
    }];
}

-(void)getAllOrder:(NSString *)helpid
          distance:(NSString *)distanceorder
         dateOrder:(NSString *)dateorder
   distanceAnddate:(NSString *)distanceAnddate
         serviceId:(NSString *)serviceid
         longitude:(NSNumber *)longitude
          latitude:(NSNumber *)latitude
            pageNo:(NSNumber *)pageno
          pageSize:(NSNumber *)pagesize
        completion:(void (^)(NSArray *, NSError *))completionHanlder{
    NSString *URL = @"HelperOrder/GetStayOrderList";
    NSDictionary *params = @{
                             @"HelperId": helpid,
                             @"DistanceOrder": distanceorder,
                             @"SelectServiceDateOrder":dateorder,
                             @"DisAndServiceDateOrder":distanceAnddate,
                             @"ServiceCat1Id":serviceid,
                             @"HelperLongitude":longitude,
                             @"HelperLatitude":latitude,
                             @"PageNo":pageno,
                             @"PageSize":pagesize
                             
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:YES];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSArray *items = [self unboxedValue:result error:&err];
            completionHanlder(items, err);
        }
    }];
}











@end
